# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///C:/Users/tedu/Desktop/NSD2407/html/register.html'
driver.get(url)
# 如果出现弹框
driver.find_element(By.CSS_SELECTOR, '#alert').click()
sleep(3)
# 处理掉弹框
# 切换到弹框，执行点击确定/取消
alert = driver.switch_to.alert
# alert.accept()  # 确定
alert.dismiss()  # 取消
# 定位用户名文本框并输入值
driver.find_element(By.CSS_SELECTOR, '#user').send_keys('admin')

sleep(3)
driver.quit()